import React from 'react';
import util from '../util';
class Layout extends React.Component {
  static contextTypes = {
    router: React.PropTypes.object
  }
  constructor(props) {
    super(props);
    this.displayName = 'Layout';
  }
  componentDidMount() {
    const listenBefore = this.context.router.listenBefore((location) => {
      const {
        pathname,
        query,
      } = location;
      if(!pathname.match(/^\/e\/.*/)){
        setTimeout(()=>{
          listenBefore();
          window.location.replace('/#'+pathname + '?' + util.body(query));
        }, 0)
      }
      //return false;
    });
  }
  render() {
    return this.props.children;
  } 
}
 
export default Layout;
